package com.lwl.Algorithmic_data_structure.class17经典递归;

/**
 * @author lwl
 * @Description 暴力递归汉诺塔问题, 六合一版本可以看Code02_Hanoi，现在是从那里抽象来的
 * @date 2023/6/2 11:06
 */
public class Code01Hanoi {

    public static void main(String[] args) {
        hanoi(4);
    }

    public static void hanoi(int n) {
        moveA2C(n, "A", "C", "B");
    }

    private static void moveA2C(int n, String from, String to, String other) {
        if (n == 1) {
            System.out.println("move 1 from " + from + " to " + to);
            return;
        }
        moveA2C(n - 1, from, other, to);
        System.out.println("move " + n + " from " + from + " to " + to);
        moveA2C(n - 1, other, to, from);
    }
}
